var index = 1;



function changeQueryField(input)
{  
  var $textfield=$(input);
  if($textfield.val() !== "")
  {
    if($textfield.closest('tr').next('.line').length <= 0)
    {
      var workline='<tr class="line">'
        + '<td><input class="queryTextbox" type="text" name="custom['+index+'][0]" onchange="changeQueryField(this)" value="" /></td>'
        + '<td><select name="custom['+index+'][1]">'
        + '<option value="1">Alle Geräte</option>'
        + '<option value="2">Computer</option>'
        + '<option value="3">Drucker</option>'
        + '</select></td>'
        + '<td></td>'
        + '</tr>';
      $textfield.closest('tbody').append(workline);
      index++;
    }
  }
  else
  {
    $textfield.closest('tr').remove();
    $textfield.remove();
  }
}

function deleteQuery(td,id)
{
  if(confirm("Abfrage wirklich löschen?"))
  {
    td.innerHTML='<img src="../design/pictures/loading.gif" width="20px" alt="..." />';
   $.post("ajax/removeCustom.php",{"id":id}).done(function(data)
   {
     if(data==="true")
     {$(td).closest('tr').fadeTo(400,0,function(){$(this).remove();});}
   });   
   //});
  }
}